home *** CD-ROM | disk | FTP | other *** search
- /*
- File: DebugUtil.h
-
- Contains: A Sample application for dictionary access.
-
- Version: Technology: System 8
- Release: Daruma Developer Release 1
-
- Copyright: 1998 by Apple Computer, Inc., all rights reserved
-
- Contact: daruma@apple.com
-
- */
-
-
- #ifndef __DEBUGUTIL__
- #define __DEBUGUTIL__
-
- #include <Types.h>
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import on
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=mac68k
- #endif
-
- extern void DebugPrint( char * assertionString,
- char * exceptionString,
- char * errorString,
- char * fileName,
- long lineNumber,
- void * value);
-
- #define QuoteExceptionString(x) #x
-
- /********************************************************************
-
- MACRO
- require(assertion, exception)
-
- DESCRIPTION
- require will test assertion and if it fails:
- break into the debugger if debugging is on.
- goto exception.
-
- ********************************************************************/
- #if DEBUG_BUILD
- #define require(assertion, exception) \
- do { \
- if (assertion) ; \
- else { \
- DebugPrint( QuoteExceptionString(assertion), \
- QuoteExceptionString(exception), \
- nil, __FILE__, __LINE__, 0); \
- goto exception; \
- } \
- } while (false)
- #else
- #define require(assertion, exception) \
- do { \
- if (assertion) ; \
- else { \
- goto exception; \
- } \
- } while (false)
- #endif
-
-
- /********************************************************************
-
- MACRO
- nrequire(assertion, exception)
-
- DESCRIPTION
- nrequire will test !assertion and if it fails:
- break into the debugger if debugging is on.
- goto exception.
-
- ********************************************************************/
- #if DEBUG_BUILD
- #define nrequire(assertion, exception) \
- do { \
- void* __privateAssertion = (void*)(assertion); \
- \
- if (__privateAssertion) { \
- DebugPrint( QuoteExceptionString(assertion), \
- QuoteExceptionString(exception), nil, \
- __FILE__, __LINE__, __privateAssertion); \
- goto exception; \
- } \
- } while (false)
- #else
- #define nrequire(assertion, exception) \
- do { \
- if (assertion) { \
- goto exception; \
- } \
- } while (false)
- #endif
-
-
- /********************************************************************
-
- MACRO
- require_action(assertion, exception, action)
-
- DESCRIPTION
- require_action will test assertion and if it fails:
- break into the debugger if debugging is on.
- execute action.
- goto exception.
-
- ********************************************************************/
- #if DEBUG_BUILD
- #define require_action(assertion, exception, action) \
- do { \
- if (assertion) ; \
- else { \
- DebugPrint( QuoteExceptionString(assertion), \
- QuoteExceptionString(exception), \
- nil, __FILE__, __LINE__, 0); \
- { action } \
- goto exception; \
- } \
- } while (false)
- #else
- #define require_action(assertion, exception, action) \
- do { \
- if (assertion) ; \
- else { \
- { action } \
- goto exception; \
- } \
- } while (false)
- #endif
-
-
- /********************************************************************
-
- MACRO
- nrequire_action(assertion, exception, action)
-
- DESCRIPTION
- nrequire_action will test !assertion and if it fails:
- break into the debugger if debugging is on.
- execute action.
- goto exception.
-
- ********************************************************************/
- #if DEBUG_BUILD
- #define nrequire_action(assertion, exception, action) \
- do { \
- void* __privateAssertion = (void*)(assertion); \
- \
- if (__privateAssertion) { \
- DebugPrint( QuoteExceptionString(assertion), \
- QuoteExceptionString(exception), nil, \
- __FILE__, __LINE__, __privateAssertion); \
- { action } \
- goto exception; \
- } \
- } while (false)
- #else
- #define nrequire_action(assertion, exception, action) \
- do { \
- if (assertion) { \
- { action } \
- goto exception; \
- } \
- } while (false)
- #endif
-
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif
-